import os
""""""
domain = 'http://www.bengou.com'
decode = "utf-8"
dataFilePath = os.path.join(os.getcwd(),'data')
splitLogString = '<#-#>'

#---------------------------------dir_path--------------------------------------------

downPath = os.path.join(dataFilePath,'down')
downHtmlPath = os.path.join(downPath,'html')
dirPathLog = os.path.join(dataFilePath,'logs')
dirPathLogSplit = os.path.join(dirPathLog,'split')
dirPathLogPic = os.path.join(dirPathLog,'pic')

#---------------------------------file_path--------------------------------------------

filePathBookIndexUrlLog = os.path.join(dirPathLogSplit,'%s_%s.log')
filePathBengouBookIndexLog = os.path.join(dirPathLog,'book_index_url.log')

#---------------------------------bengou url---------------------------------------

searchTargetUrl = "http://www.bengou.com/folder/folderList2.jsp?letter=%s&demo=3&page=%d"
letterList = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0']
ruleSearchTarget = "http://www.bengou.com/folder/folderList2.jsp\?letter=%s&demo=3&page=(?P<page>\d*)"
#------------------------------------ Fileter Rule -----------------------------------------

bengouFileterRule = """
    replylist2\.jsp|javascript:
    |\#                                           #need \ for this string
    |http://www\.bengou\.com/zt/61/                 #topic html
    |http://www\.bengou\.com/include/               #include dongman
    |http://www\.bengou\.com/author/                #author info html
    |http://www\.bengou\.com/update/lastweek\.html   #update for lastweek html
    |&page=0
    """
bengouFileterForTopicRule = """
    http://www\.bengou\.com/zt/61/                  #topic html
    |http://www\.bengou\.com/update/lastweek\.html   #update for lastweek html
    |http://www\.bengou\.com/include/
    """
bengouFileterDomainRule = "[a-zA-z]+://www*\.bengou\.com"
FileterUrlFileRule = "\.html|\.htm|\.jsp|\.php|\.asp"

#--------------------------------- get info Rule --------------------------------------------

ruleFilePathFromPicUrl = "http://pic(?P<pic_id>\d+)\.bengou.com/comicdata/(?P<file_path>.*?(\.[pP][nN][gG]|\.[jJ][pP][gG]|\.[bB][mM][pP]|\.[gG][iI][fF]))"
ruleScriptTxt = """<SCRIPT(?:[^<]+|<(?!/SCRIPT>))*</SCRIPT>"""
rulePicHtmlTree = "pictree.=.\[(.*?)\]"
ruleHostUrl = "^(.*)(?<=/)"
ruleImgSrcForIdDisp = """<img.*?\sid=['"]disp['"].*?\ssrc=['"](.*?)['"].*?>"""
ruleAllBookIndex = """<a[^>]*href=["|'](?P<id_1>\d*)/(?P<id_2>\d*).html["|'].*?>(.*?)</a>"""
ruleHrefForA = """<a[^>]*href=["|'](.*?)["|'].*?>(.*?)</a>"""
ruleBengouBookInfo = """[a-zA-z]+://www\.bengou\.com(.*)/(\d*?)/(\d*?)\.html"""
ruleHostPathForUrl = "(.*)(?<=/)"
ruleBookIndex = """/\d*/\w*/index.html"""
ruleSplitBookIndex = """.*/(.\d*)/(.\w*)/index.html"""

